package version_2;

import java.io.*;

/**
 * Person.java
 * wzz -11923040205
 * 2020.6.10
 * version 2
 * */
class Person implements Serializable {
    protected String name;
    protected String address;
    protected String phone_number;
    protected String email;

    public Person(String name){
        this.name=name;
    }
    public Person(){
    }

    @Override
    public String toString(){
        return "Person:"+name;
    }

    //序列化方法
    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new Person(name));
    }
}

class Student extends Person{
    protected String grade;

    public Student(String name) {
        super(name);
    }

    @Override
    public String toString(){
        return "Student:"+name;
    }

    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new Student(name));
    }
}

class Employee extends Person{
    protected String office;
    protected int salary;
    protected String date_engagement;

    public Employee(String name) {
        super(name);
    }

    @Override
    public String toString(){
        return "Employee:"+name;
    }

    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new Employee(name));
    }
}

class MyDate{
    int year;
    int month;
    int day;
}

class Faculty extends Employee{
    //办公时间
    protected String office_hours;
    //级别
    protected String rank;

    public Faculty(String name) {
        super(name);
    }


    @Override
    public String toString(){
        return "Faculty:"+name;
    }

    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new Faculty(name));
    }
}

class staff extends Employee{
    //职务称号
    String title;

    public staff(String name) {
        super(name);
    }

    @Override
    public String toString(){
        return "Staff:"+name;
    }

    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new staff(name));
    }
}

class Postgraduate extends Student{
    protected String research_direction;
    protected String tutor;

    public Postgraduate(String name) {
        super(name);
    }

    @Override
    public String toString(){
        return "Postgraduate:"+name;
    }

    public void writeToFile(File f) throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
        oos.writeObject(new Postgraduate(name));
    }
}